-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCoordinatorMaster.java
More file actions
89 lines (66 loc) · 2.53 KB
/
CoordinatorMaster.java
File metadata and controls
89 lines (66 loc) · 2.53 KB
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
import java.io.*;
import java.util.*;
import javafx.beans.property.*;
public class CoordinatorMaster {
private ObjectProperty<ProcessRun> run = new SimpleObjectProperty<>();
public final ProcessRun getRun() { return run.get(); }
public final void setRun(ProcessRun value) { run.set(value); }
public ObjectProperty<ProcessRun> runProperty() { return run; }
public ProcessRunFilter runFilter;
private UIMainWindow mainWindow;
private UIPlayControls playControls;
public void exec() {
UIUtils.initializeColorWheel();
setRun(new ProcessRun());
runFilter = new ProcessRunFilter();
mainWindow = new UIMainWindow(this);
playControls = new UIPlayControls(this);
mainWindow.display();
playControls.display();
loadConfigFile();
}
public void queryProcessRunAndUpdateUI() {
// TODO: add data for other tabs
if (!getRun().isNull()) {
UIUtils.resetColorIndex();
mainWindow.updateUI(runFilter.getSourceLine(getRun()),
runFilter.getAssembly(getRun()),
runFilter.getStack(getRun()),
runFilter.getRegisters(getRun()),
runFilter.getVariables(getRun()),
runFilter.getSections(getRun()));
}
}
public void closeProgram() {
boolean answer = UIConfirmBox.display("Confirm Exit", "Are you sure you want to exit?");
if (answer) {
saveConfigFile();
for (UIDetachedTab tab : mainWindow.detachedTabs) tab.window.close();
playControls.window.close();
mainWindow.window.close();
}
}
public void loadConfigFile() {
try (BufferedReader reader = new BufferedReader(new FileReader("./config.txt"))) {
List<String> lines = new ArrayList<String>();
String line = null;
while ((line = reader.readLine()) != null) lines.add(line + System.lineSeparator());
mainWindow.loadConfig(lines);
playControls.loadConfig(lines);
runFilter.loadConfig(lines);
} catch (IOException ex) {
System.err.println("Error loading config file, proceeding with default values.");
}
}
public void saveConfigFile() {
try (BufferedWriter writer = new BufferedWriter(new FileWriter("./config.txt"))) {
String out = "";
out += mainWindow.saveConfig();
out += playControls.saveConfig();
out += runFilter.saveConfig();
writer.write(out);
} catch (IOException ex) {
System.err.println("Error saving config file!");
}
}
}