1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
|
/*******************************************************************************
* Copyright (c) 2007 Wind River Systems, Inc. and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Wind River Systems - initial API and implementation
*******************************************************************************/
package com.windriver.debug.tcf.ui.model;
import com.windriver.tcf.api.protocol.IToken;
import com.windriver.tcf.api.services.IMemory;
import com.windriver.tcf.api.services.IRunControl;
public class TCFChildrenExecContext extends TCFChildren {
private boolean mem_valid;
private boolean run_valid;
TCFChildrenExecContext(TCFNode node) {
super(node);
}
@Override
boolean validate(TCFRunnable done) {
if (!mem_valid && !validateMemoryChildren(done)) return false;
if (!run_valid && !validateRunControlChildren(done)) return false;
doneValidate();
return true;
}
@Override
void invalidate() {
mem_valid = false;
run_valid = false;
super.invalidate();
}
private boolean validateMemoryChildren(TCFRunnable done) {
assert node.data_command == null;
IMemory mem = node.model.getLaunch().getService(IMemory.class);
if (mem == null) {
mem_valid = true;
return true;
}
if (done != null) node.wait_list.add(done);
node.data_command = mem.getChildren(node.id, new IMemory.DoneGetChildren() {
public void doneGetChildren(IToken token, Exception error, String[] contexts) {
if (node.data_command != token) return;
node.data_command = null;
if (error != null) {
node.node_error = error;
}
else {
for (int i = 0; i < contexts.length; i++) {
String id = contexts[i];
TCFNode n = node.model.getNode(id);
if (n == null) n = new TCFNodeExecContext(node, id);
children_next.put(id, n);
}
}
mem_valid = true;
node.validateNode(null);
}
});
return false;
}
private boolean validateRunControlChildren(TCFRunnable done) {
assert node.data_command == null;
IRunControl run = node.model.getLaunch().getService(IRunControl.class);
if (run == null) {
run_valid = true;
return true;
}
if (done != null) node.wait_list.add(done);
node.data_command = run.getChildren(node.id, new IRunControl.DoneGetChildren() {
public void doneGetChildren(IToken token, Exception error, String[] contexts) {
if (node.data_command != token) return;
node.data_command = null;
if (error != null) {
node.node_error = error;
}
else {
for (String id : contexts) {
TCFNode n = node.model.getNode(id);
if (n == null) n = new TCFNodeExecContext(node, id);
children_next.put(id, n);
}
}
run_valid = true;
node.validateNode(null);
}
});
return false;
}
}
|