]> git.argeo.org Git - gpl/argeo-slc.git/blob - eclipse/plugins/org.argeo.slc.client.core/src/main/java/org/argeo/slc/client/contentprovider/ProcessDetailContentProvider.java
Implementation of a first draft of editorView for the process parameters.
[gpl/argeo-slc.git] / eclipse / plugins / org.argeo.slc.client.core / src / main / java / org / argeo / slc / client / contentprovider / ProcessDetailContentProvider.java
1 package org.argeo.slc.client.contentprovider;
2
3 import java.util.List;
4
5 import org.apache.commons.logging.Log;
6 import org.apache.commons.logging.LogFactory;
7 import org.argeo.slc.process.RealizedFlow;
8 import org.argeo.slc.process.SlcExecution;
9 import org.argeo.slc.process.SlcExecutionStep;
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. For now, only a basic list of
15 * details is displayed, not a tree.
16 */
17 public class ProcessDetailContentProvider implements ITreeContentProvider {
18 private final static Log log = LogFactory
19 .getLog(ProcessDetailContentProvider.class);
20
21 private SlcExecution slcExecution;
22
23 // private List<SlcAgent> slcAgents;
24
25 public Object[] getChildren(Object parent) {
26 if (parent instanceof SlcExecution) {
27 slcExecution = (SlcExecution) parent;
28
29 List<SlcExecutionStep> steps = slcExecution.getSteps();
30 List<RealizedFlow> realizedFlows = slcExecution.getRealizedFlows();
31
32 for (int i = 0; i < steps.size(); i++) {
33 log.debug("step[" + i + "] : " + steps.get(i).getType());
34 }
35 for (int i = 0; i < realizedFlows.size(); i++) {
36 log.debug("step[" + i + "] : "
37 + realizedFlows.get(i).toString());
38 }
39
40 log.debug(" Realized flows : ");
41 return steps.toArray();
42 }
43 // if (parent instanceof ExecutionModuleNode) {
44 // ExecutionModuleNode executionModuleNode = (ExecutionModuleNode)
45 // parent;
46 // ExecutionModuleDescriptor emd =
47 // executionModuleNode.getDescriptor();
48 // emd = executionModuleNode.getAgentNode().getAgent()
49 // .getExecutionModuleDescriptor(emd.getName(),
50 // emd.getVersion());
51 // executionModuleNode.cacheDescriptor(emd);
52 // // for (String flowName :
53 // executionModuleNode.getFlowDescriptors()
54 // // .keySet()) {
55 // // executionModuleNode.addChild(new FlowNode(flowName,
56 // // executionModuleNode));
57 // // }
58 // return executionModuleNode.getChildren();
59 // } else if (parent instanceof AgentNode) {
60 // AgentNode agentNode = (AgentNode) parent;
61 //
62 // if (log.isTraceEnabled())
63 // log.trace("Scan agent " + agentNode);
64 //
65 // agentNode.clearChildren();
66 // for (ExecutionModuleDescriptor desc : agentNode.getAgent()
67 // .listExecutionModuleDescriptors()) {
68 // agentNode.addChild(new ExecutionModuleNode(agentNode, desc));
69 // }
70 //
71 // return agentNode.getChildren();
72 // } else if (parent instanceof TreeParent) {
73 // return ((TreeParent) parent).getChildren();
74 // } else if (parent instanceof FlowNode) {
75 // return new Object[0];
76 // } else {
77 // List<AgentNode> agentNodes = new ArrayList<AgentNode>();
78 // for (SlcAgent slcAgent : slcAgents) {
79 // agentNodes.add(new AgentNode(slcAgent));
80 // }
81 // return agentNodes.toArray();
82 // }
83 return null;
84 }
85
86 public Object getParent(Object node) {
87 // if (node instanceof TreeObject) {
88 // return ((TreeObject) node).getParent();
89 // }
90 return null;
91 }
92
93 public boolean hasChildren(Object parent) {
94 return false;
95 }
96
97 public void inputChanged(Viewer v, Object oldInput, Object newInput) {
98 }
99
100 public void dispose() {
101 }
102
103 public Object[] getElements(Object parent) {
104 // return getChildren(parent);
105 // Here we must duplicate the code otherwise the inner call to method
106 // getChildren(parent); is not intercepted by AspectJ
107 if (parent instanceof SlcExecution) {
108 slcExecution = (SlcExecution) parent;
109
110 List<SlcExecutionStep> steps = slcExecution.getSteps();
111 List<RealizedFlow> realizedFlows = slcExecution.getRealizedFlows();
112
113 for (int i = 0; i < steps.size(); i++) {
114 log.debug("step[" + i + "] : " + steps.get(i).getType());
115 }
116 for (int i = 0; i < realizedFlows.size(); i++) {
117 log.debug("step[" + i + "] : "
118 + realizedFlows.get(i).toString());
119 }
120
121 log.debug(" Realized flows : ");
122 return steps.toArray();
123 }
124 return null;
125 }
126 }